home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / misc / dspice0s / spice.c < prev    next >
C/C++ Source or Header  |  1992-11-21  |  30KB  |  891 lines

  1. /* spice.f -- translated by f2c (version of 3 February 1990  3:36:42).
  2.    You must link the resulting object file with the libraries:
  3.     -lF77 -lI77 -lm -lc   (in that order)
  4. */
  5.  
  6. #include "f2c.h"
  7.  
  8. /* Common Block Declarations */
  9.  
  10. struct {
  11.     integer ielmnt, isbckt, nsbckt, iunsat, nunsat, itemps, numtem, isens, 
  12.         nsens, ifour, nfour, ifield, icode, idelim, icolum, insize, 
  13.         junode, lsbkpt, numbkp, iorder, jmnode, iur, iuc, ilc, ilr, 
  14.         numoff, isr, nmoffc, iseq, iseq1, neqn, nodevs, ndiag, iswap, 
  15.         iequa, macins, lvnim1, lx0, lvn, lynl, lyu, lyl, lx1, lx2, lx3, 
  16.         lx4, lx5, lx6, lx7, ld0, ld1, ltd, imynl, imvn, lcvn, nsnod, 
  17.         nsmat, nsval, icnod, icmat, icval, loutpt, lpol, lzer, irswpf, 
  18.         irswpr, icswpf, icswpr, irpt, jcpt, irowno, jcolno, nttbr, nttar, 
  19.         lvntmp;
  20. } tabinf_;
  21.  
  22. #define tabinf_1 tabinf_
  23.  
  24. struct {
  25.     doublereal atime, aprog[3], adate, atitle[10], defl, defw, defad, defas, 
  26.         rstats[50];
  27.     integer iwidth, lwidth, nopage;
  28. } miscel_;
  29.  
  30. #define miscel_1 miscel_
  31.  
  32. struct {
  33.     doublereal achar, afield[15], oldlin[15];
  34.     integer kntrc, kntlim;
  35. } line_;
  36.  
  37. #define line_1 line_
  38.  
  39. struct {
  40.     integer locate[50], jelcnt[50], nunods, ncnods, numnod, nstop, nut, nlt, 
  41.         nxtrm, ndist, ntlin, ibr, numvs, numalt, numcyc;
  42. } cirdat_;
  43.  
  44. #define cirdat_1 cirdat_
  45.  
  46. struct {
  47.     doublereal vto, beta, gamma, phi, phib, cox, xnsub, xnfs, xd, xj, xld, 
  48.         xlamda, uo, uexp, vbp, utra, vmax, xneff, xl, xw, vbi, von, vdsat,
  49.          qspof, beta0, beta1, cdrain, xqco, xqc, fnarrw, fshort;
  50.     integer lev;
  51. } mosarg_;
  52.  
  53. #define mosarg_1 mosarg_
  54.  
  55. struct {
  56.     doublereal omega, time, delta, delold[7], ag[7], vt, xni, egfet, xmu, 
  57.         sfactr;
  58.     integer mode, modedc, icalc, initf, method, iord, maxord, noncon, iterno, 
  59.         itemno, nosolv, modac, ipiv, ivmflg, ipostp, iscrch, iofile;
  60. } status_;
  61.  
  62. #define status_1 status_
  63.  
  64. struct {
  65.     integer iprnta, iprntl, iprntm, iprntn, iprnto, limtim, limpts, lvlcod, 
  66.         lvltim, itl1, itl2, itl3, itl4, itl5, itl6, igoof, nogo, keof;
  67. } flags_;
  68.  
  69. #define flags_1 flags_
  70.  
  71. struct {
  72.     doublereal twopi, xlog2, xlog10, root2, rad, boltz, charge, ctok, gmin, 
  73.         reltol, abstol, vntol, trtol, chgtol, eps0, epssil, epsox, pivtol,
  74.          pivrel;
  75. } knstnt_;
  76.  
  77. #define knstnt_1 knstnt_
  78.  
  79. struct {
  80.     doublereal cpyknt;
  81.     integer istack[1], lorg, icore, maxcor, maxuse, memavl, ldval, numblk, 
  82.         loctab, ltab, ifwa, nwoff, ntab, maxmem, memerr, nwd4, nwd8, 
  83.         nwd16;
  84. } memmgr_;
  85.  
  86. #define memmgr_1 memmgr_
  87.  
  88. struct {
  89.     doublereal tcstar[2], tcstop[2], tcincr[2];
  90.     integer icvflg, itcelm[2], kssop, kinel, kidin, kovar, kidout;
  91. } dc_;
  92.  
  93. #define dc_1 dc_
  94.  
  95. struct {
  96.     doublereal fstart, fstop, fincr, skw2, refprl, spw2;
  97.     integer jacflg, idfreq, inoise, nosprt, nosout, nosin, idist, idprt;
  98. } ac_;
  99.  
  100. #define ac_1 ac_
  101.  
  102. struct {
  103.     doublereal tstep, tstop, tstart, delmax, tdmax, forfre;
  104.     integer jtrflg;
  105. } tran_;
  106.  
  107. #define tran_1 tran_
  108.  
  109. struct {
  110.     doublereal xincr, string[15], xstart, yvar[8];
  111.     integer itab[8], itype[8], ilogy[8], npoint, numout, kntr, numdgt;
  112. } outinf_;
  113.  
  114. #define outinf_1 outinf_
  115.  
  116. struct {
  117.     integer maxtim, itime, icost;
  118. } cje_;
  119.  
  120. #define cje_1 cje_
  121.  
  122. struct {
  123.     integer idebug[20];
  124. } debug_;
  125.  
  126. #define debug_1 debug_
  127.  
  128. struct {
  129.     doublereal value[200000];
  130. } blank_;
  131.  
  132. #define blank_1 blank_
  133.  
  134. /* Table of constant values */
  135.  
  136. static integer c__50 = 50;
  137. static integer c_n1 = -1;
  138. static integer c__1 = 1;
  139.  
  140. /* spice version 2g.6  sccsid=root.ma 3/15/83 */
  141. /*<       program spice >*/
  142. /* Main program */ MAIN__()
  143. {
  144.     /* Initialized data */
  145.  
  146.     static struct {
  147.     char e_1[8];
  148.     doublereal e_2;
  149.     } equiv_30 = { {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, 0. };
  150.  
  151. #define ablnk (*(doublereal *)&equiv_30)
  152.  
  153.     static struct {
  154.     char e_1[32];
  155.     doublereal e_2;
  156.     } equiv_31 = { {'j', 'o', 'b', ' ', 's', 't', 'a', 't', 'i', 's', 't',
  157.          'i', 'c', 's', ' ', 's', 'u', 'm', 'm', 'a', 'r', 'y', ' ', 
  158.         ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, 0. };
  159.  
  160. #define acctit ((doublereal *)&equiv_31)
  161.  
  162.     static struct {
  163.     char e_1[8];
  164.     doublereal e_2;
  165.     } equiv_32 = { {' ', ' ', 's', 'p', 'i', 'c', 'e', ' '}, 0. };
  166.  
  167. #define ahdr1 (*(doublereal *)&equiv_32)
  168.  
  169.     static struct {
  170.     char e_1[8];
  171.     doublereal e_2;
  172.     } equiv_33 = { {'2', 'g', '.', '6', ' ', ' ', ' ', ' '}, 0. };
  173.  
  174. #define ahdr2 (*(doublereal *)&equiv_33)
  175.  
  176.     static struct {
  177.     char e_1[8];
  178.     doublereal e_2;
  179.     } equiv_34 = { {'3', '/', '1', '5', '/', '8', '3', ' '}, 0. };
  180.  
  181. #define ahdr3 (*(doublereal *)&equiv_34)
  182.  
  183.  
  184.     /* Format strings */
  185.     static char fmt_301[] = "(\0020\002,9x,\002***** job aborted\002)";
  186.     static char fmt_306[] = "(\0020\002,9x,\002***** this parameter change i\
  187. s illegal\002)";
  188.     static char fmt_311[] = "(\0020\002,/,9x,\002job concluded\002)";
  189.     static char fmt_361[] = "(\002   nunods ncnods numnod numel  diodes  bjt\
  190. s  jfets  mfets\002//,i9,2i7,i6,i8,i6,2i7)";
  191.     static char fmt_371[] = "(/\0020  numtem icvflg jtrflg jacflg inoise  id\
  192. ist   nogo\002/,\0020 \002,7i7)";
  193.     static char fmt_381[] = "(/\0020  nstop   nttbr   nttar   ifill    iops \
  194.    perspa\002//,1x,5f8.0,f9.3)";
  195.     static char fmt_391[] = "(/\0020  numttp  numrtp  numnit  maxmem  memuse\
  196.   copyknt\002,//,2x,3f8.0,2x,i6,2x,i6,2x,f8.0)";
  197.     static char fmt_401[] = "(/,\0020\002,9x,\002readin  \002,12x,f10.2/,\
  198. \0020\002,9x,\002setup   \002,12x,f10.2/,\0020\002,9x,\002trcurv  \002,12x,f\
  199. 10.2,10x,f6.0/,\0020\002,9x,\002dcan    \002,12x,f10.2,10x,f6.0/,\0020\002,9\
  200. x,\002dcdcmp  \002,12x,f10.3,10x,f6.0/,\0020\002,9x,\002dcsol   \002,12x,f10\
  201. .3/,\0020\002,9x,\002acan    \002,12x,f10.2,10x,f6.0/,\0020\002,9x,\002trana\
  202. n  \002,12x,f10.2,10x,f6.0/,\0020\002,9x,\002output  \002,12x,f10.2)";
  203.     static char fmt_402[] = "(\0020\002,9x,\002load    \002,12x,f10.3/,\002\
  204. 0\002,9x,\002codgen  \002,12x,f10.3,10x,f6.0/,\0020\002,9x,\002codexc  \002,\
  205. 12x,f10.3/,\0020\002,9x,\002macins  \002,12x,f10.3)";
  206.     static char fmt_801[] = "(\0020\002,9x,\002overhead\002,12x,f10.2)";
  207.     static char fmt_811[] = "(\0020\002,9x,\002total job time      \002,f10.\
  208. 2)";
  209.     static char fmt_901[] = "(\0021warning:  further analysis stopped due to\
  210.  cpu time limit\002/)";
  211.     static char fmt_1001[] = "(/1x,\002input deck (file) contains no data\
  212. .\002)";
  213.  
  214.     /* System generated locals */
  215.     integer i_1;
  216.  
  217.     /* Builtin functions */
  218.     double atan2(), log(), sqrt();
  219.     integer s_wsfe(), e_wsfe(), do_fio();
  220.     /* Subroutine */ int s_stop();
  221.  
  222.     /* Local variables */
  223.     extern /* Subroutine */ int acan_(), dcop_();
  224.     static doublereal time1, time2;
  225.     extern /* Subroutine */ int zero8_();
  226.     static integer i;
  227.     static doublereal ohead;
  228.     extern integer iargc_();
  229.     extern /* Subroutine */ int xtime_(), xdate_(), setup_(), alter_();
  230.     static integer numel;
  231.     extern /* Subroutine */ int title_();
  232.     static doublereal tcost;
  233.     static integer icost1;
  234.     static doublereal et;
  235.     extern /* Subroutine */ int getcje_();
  236. #define nodplc ((integer *)&blank_1)
  237. #define cvalue ((complex *)&blank_1)
  238.     extern integer iopraw_();
  239.     static integer nodata;
  240.     extern /* Subroutine */ int second_(), setmem_(), readin_(), errchk_(), 
  241.         tmpupd_(), dctran_(), ovtpvt_();
  242.  
  243.     /* Fortran I/O blocks */
  244.     static cilist io__11 = { 0, 0, 0, fmt_301, 0 };
  245.     static cilist io__12 = { 0, 0, 0, fmt_306, 0 };
  246.     static cilist io__13 = { 0, 0, 0, fmt_311, 0 };
  247.     static cilist io__16 = { 0, 0, 0, fmt_361, 0 };
  248.     static cilist io__17 = { 0, 0, 0, fmt_371, 0 };
  249.     static cilist io__18 = { 0, 0, 0, fmt_381, 0 };
  250.     static cilist io__19 = { 0, 0, 0, fmt_391, 0 };
  251.     static cilist io__20 = { 0, 0, 0, fmt_401, 0 };
  252.     static cilist io__21 = { 0, 0, 0, fmt_402, 0 };
  253.     static cilist io__26 = { 0, 0, 0, fmt_801, 0 };
  254.     static cilist io__27 = { 0, 0, 0, fmt_811, 0 };
  255.     static cilist io__28 = { 0, 0, 0, fmt_901, 0 };
  256.     static cilist io__29 = { 0, 0, 0, fmt_1001, 0 };
  257.  
  258.  
  259. /* ...  cray notes: */
  260. /* .. change data filnam to 5lspice */
  261. /* .. change call overlay .. remove last zero */
  262. /* .. change ??????program to subroutine in all but this overlay */
  263. /* .. delete overlay spice,0,0 card below */
  264. /* .. */
  265. /*<       implicit double precision (a-h,o-z) >*/
  266.  
  267.  
  268. /* spice version 2g.6  sccsid=root.ma 3/15/83 */
  269.  
  270. /*     spice is an electronic circuit simulation program that was deve- */
  271.  
  272. /* loped by the integrated circuits group of the electronics research */
  273. /* laboratory and the department of electrical engineering and computer */
  274.  
  275. /* sciences at the university of california, berkeley, california.  the */
  276.  
  277. /* program spice is available free of charge to any interested party. */
  278. /* the sale, resale, or use of this program for profit without the */
  279. /* express written consent of the department of electrical engineering */
  280. /* and computer sciences, university of california, berkeley, california, 
  281. */
  282. /* is forbidden. */
  283.  
  284.  
  285. /*     the present version is based on the spice2 program versions 2e.3 */
  286.  
  287. /* and 2f.1 developed at the university of california berkeley and the */
  288. /* hewlett-packard spice version 2.7. */
  289. /*     this version is designed to be transportable on most computers */
  290. /* with an ansi fortran compiler and enough memory space for code and */
  291. /* data. the memory manager uses the function 'locf' to find the */
  292. /* address of a pointer; this function must be provided. */
  293.  
  294.  
  295. /* implementation notes: */
  296.  
  297. /*     subroutines mclock and mdate return the time (as hh:mm:ss) and */
  298. /* the date (as dd mmm yy), respectively.  subroutine getcje returns in */
  299.  
  300. /* common block /cje/ various attributes of the current job environment. 
  301. */
  302. /* spice expects getcje to set /cje/ variables maxtim, itime, and icost. 
  303. */
  304. /* maxtim is the maximum cpu time in seconds, itime is the elapsed cpu */
  305. /* time in seconds, and icost is the job cost in cents. */
  306. /* subroutine memory is used to change the number of memory words */
  307. /* allocated to spice.  if the amount of memory allocated to a jobstep */
  308. /* is fixed, subroutine memory need not be changed. */
  309. /*     subroutine second(t) returns the time in seconds and is used */
  310. /* for timing purposes. it must be provided where not available. */
  311. /*     ifamwa (set in a data statement below) should be set to the */
  312. /* address of the first available word of memory (following overlays, if 
  313. */
  314. /* any).  the proper value should be easily obtainable from any load map. 
  315. */
  316. /* ifamwa is used only on computers where the program (spice) can change 
  317. */
  318. /* the allocated memory dynamically at run time according to circuit 
  319. size. */
  320. /* (see also comments under subroutine setmem). */
  321. /*     all berkeley spice2.f release versions do not implement the ifamwa 
  322. */
  323. /* feature due to its dependence on operating system. */
  324. /*     with the exception of most flags, all data in spice are stored in 
  325. */
  326. /* the form of managed tables allocated in the /blank/ array value(). */
  327. /* array value() can be redimensioned in the main program according to */
  328. /* memory availability at each user site. it should be noted again that */
  329.  
  330. /* the program dynamically manages its data within the bounds of array */
  331. /* value(). */
  332. /*     the vax release versions assume the virtual memory feature and */
  333. /* dimension value() to 200,000 double precision words. */
  334. /*     the cdc and ibm versions dimension value() to 20000 real or */
  335. /* real*8 words, respectively. */
  336. /*     spice is particularly well-suited to being run using a one-level */
  337.  
  338. /* overlay structure beginning with routines spice (the overlay root), */
  339. /* readin, errchk, setup, dctran, dcop, acan, and ovtpvt.  the order of */
  340.  
  341. /* the routines in this listing corresponds to that structure.  note */
  342. /* that if cdc explicit overlaying is to be used, an overlay directive */
  343. /* card must be inserted before the first line of each of the just-named 
  344. */
  345. /* routines. */
  346.  
  347.  
  348. /* spice version 2g.6  sccsid=tabinf 3/15/83 */
  349. /*<       common /tabinf/ ielmnt,isbckt,nsbckt,iunsat,nunsat,itemps,numtem, >*/
  350. /*<      1   isens,nsens,ifour,nfour,ifield,icode,idelim,icolum,insize, >*/
  351. /*<      2   junode,lsbkpt,numbkp,iorder,jmnode,iur,iuc,ilc,ilr,numoff,isr, >*/
  352. /*<      3   nmoffc,iseq,iseq1,neqn,nodevs,ndiag,iswap,iequa,macins,lvnim1, >*/
  353. /*<      4   lx0,lvn,lynl,lyu,lyl,lx1,lx2,lx3,lx4,lx5,lx6,lx7,ld0,ld1,ltd, >*/
  354. /*<      5   imynl,imvn,lcvn,nsnod,nsmat,nsval,icnod,icmat,icval, >*/
  355. /*<      6   loutpt,lpol,lzer,irswpf,irswpr,icswpf,icswpr,irpt,jcpt, >*/
  356. /*<      7   irowno,jcolno,nttbr,nttar,lvntmp >*/
  357. /* spice version 2g.6  sccsid=miscel 3/15/83 */
  358. /*<       common /miscel/ atime,aprog(3),adate,atitle(10),defl,defw,defad, >*/
  359. /*<      1  defas,rstats(50),iwidth,lwidth,nopage >*/
  360. /* spice version 2g.6  sccsid=line 3/15/83 */
  361. /*<       common /line/ achar,afield(15),oldlin(15),kntrc,kntlim >*/
  362. /* spice version 2g.6  sccsid=cirdat 3/15/83 */
  363. /*<       common /cirdat/ locate(50),jelcnt(50),nunods,ncnods,numnod,nstop, >*/
  364. /*<      1   nut,nlt,nxtrm,ndist,ntlin,ibr,numvs,numalt,numcyc >*/
  365. /* spice version 2g.6  sccsid=mosarg 3/15/83 */
  366. /*<       common /mosarg/ vto,beta,gamma,phi,phib,cox,xnsub,xnfs,xd,xj,xld, >*/
  367. /*<      1   xlamda,uo,uexp,vbp,utra,vmax,xneff,xl,xw,vbi,von,vdsat,qspof, >*/
  368. /*<      2   beta0,beta1,cdrain,xqco,xqc,fnarrw,fshort,lev >*/
  369. /* spice version 2g.6  sccsid=status 3/15/83 */
  370. /*<       common /status/ omega,time,delta,delold(7),ag(7),vt,xni,egfet, >*/
  371. /*<      1   xmu,sfactr,mode,modedc,icalc,initf,method,iord,maxord,noncon, >*/
  372. /*<      2   iterno,itemno,nosolv,modac,ipiv,ivmflg,ipostp,iscrch,iofile >*/
  373. /* spice version 2g.6  sccsid=flags 3/15/83 */
  374. /*<       common /flags/ iprnta,iprntl,iprntm,iprntn,iprnto,limtim,limpts, >*/
  375. /*<      1   lvlcod,lvltim,itl1,itl2,itl3,itl4,itl5,itl6,igoof,nogo,keof >*/
  376. /* spice version 2g.6  sccsid=knstnt 3/15/83 */
  377. /*<       common /knstnt/ twopi,xlog2,xlog10,root2,rad,boltz,charge,ctok, >*/
  378. /*<      1   gmin,reltol,abstol,vntol,trtol,chgtol,eps0,epssil,epsox, >*/
  379. /*<      2   pivtol,pivrel >*/
  380. /* spice version 2g.6  sccsid=memmgr 3/15/83 */
  381. /*<       common /memmgr/ cpyknt,istack(1),lorg,icore,maxcor,maxuse,memavl, >*/
  382. /*<      1   ldval,numblk,loctab,ltab,ifwa,nwoff,ntab,maxmem,memerr,nwd4, >*/
  383. /*<      2   nwd8,nwd16 >*/
  384. /* spice version 2g.6  sccsid=dc 3/15/83 */
  385. /*<       common /dc/ tcstar(2),tcstop(2),tcincr(2),icvflg,itcelm(2),kssop, >*/
  386. /*<      1   kinel,kidin,kovar,kidout >*/
  387. /* spice version 2g.6  sccsid=ac 3/15/83 */
  388. /*<       common /ac/ fstart,fstop,fincr,skw2,refprl,spw2,jacflg,idfreq, >*/
  389. /*<      1   inoise,nosprt,nosout,nosin,idist,idprt >*/
  390. /* spice version 2g.6  sccsid=tran 3/15/83 */
  391. /*<       common /tran/ tstep,tstop,tstart,delmax,tdmax,forfre,jtrflg >*/
  392. /* spice version 2g.6  sccsid=outinf 3/15/83 */
  393. /*<       common /outinf/ xincr,string(15),xstart,yvar(8),itab(8),itype(8), >*/
  394. /*<      1   ilogy(8),npoint,numout,kntr,numdgt >*/
  395. /* spice version 2g.6  sccsid=cje 3/15/83 */
  396. /*<       common /cje/ maxtim,itime,icost >*/
  397. /* spice version 2g.6  sccsid=debug 3/15/83 */
  398. /*<       common/debug/ idebug(20) >*/
  399. /* spice version 2g.6  sccsid=blank 3/15/83 */
  400. /*<       common /blank/ value(200000) >*/
  401. /*<       integer nodplc(64) >*/
  402. /*<       complex cvalue(32) >*/
  403. /*<       equivalence (value(1),nodplc(1),cvalue(1)) >*/
  404.  
  405.  
  406.  
  407. /*<       dimension acctit(4) >*/
  408. /*<       dimension remain(4) >*/
  409. /*<       data ablnk /1h  / >*/
  410. /*<       data acctit / 8hjob stat, 8histics s, 8hummary  , 8h         / >*/
  411. /*<       data ahdr1,ahdr2,ahdr3 / 8h  spice ,8h2g.6    ,8h3/15/83     / >*/
  412.  
  413.  
  414. /*<       ipostp=0 >*/
  415.     status_1.ipostp = 0;
  416. /*     check if a raw data file should be written */
  417. /*     open file if so required */
  418. /*<       if  (iargc().gt.0) ipostp=iopraw() >*/
  419.     if (iargc_() > 0) {
  420.     status_1.ipostp = iopraw_();
  421.     }
  422. /*<       maxmem=2*200000 >*/
  423.     memmgr_1.maxmem = 400000;
  424. /*<       maxtim=1e8 >*/
  425.     cje_1.maxtim = (float)1e8;
  426. /*<       icost=0 >*/
  427.     cje_1.icost = 0;
  428. /*<       iofile=6 >*/
  429.     status_1.iofile = 6;
  430.  
  431. /*  initialization */
  432.  
  433. /*<       aprog(1)=ahdr1 >*/
  434.     miscel_1.aprog[0] = ahdr1;
  435. /*<       aprog(2)=ahdr2 >*/
  436.     miscel_1.aprog[1] = ahdr2;
  437. /*<       aprog(3)=ahdr3 >*/
  438.     miscel_1.aprog[2] = ahdr3;
  439. /*<       achar=ablnk >*/
  440.     line_1.achar = ablnk;
  441. /*<       keof=0 >*/
  442.     flags_1.keof = 0;
  443. /*<       call xtime(atime) >*/
  444.     xtime_(&miscel_1.atime);
  445. /*<       call xdate(adate) >*/
  446.     xdate_(&miscel_1.adate);
  447. /*<       boltz=1.3806226d-23 >*/
  448.     knstnt_1.boltz = 1.3806226e-23;
  449. /*<       charge=1.6021918d-19 >*/
  450.     knstnt_1.charge = 1.6021918e-19;
  451. /*<       ctok=273.15d0 >*/
  452.     knstnt_1.ctok = 273.15;
  453. /*<       eps0=8.854214871d-12 >*/
  454.     knstnt_1.eps0 = 8.854214871e-12;
  455. /*<       epssil=11.7d0*eps0 >*/
  456.     knstnt_1.epssil = knstnt_1.eps0 * 11.7;
  457. /*<       epsox=3.9d0*eps0 >*/
  458.     knstnt_1.epsox = knstnt_1.eps0 * 3.9;
  459. /*<       twopi=8.0d0*datan2(1.0d0,1.0d0) >*/
  460.     knstnt_1.twopi = atan2(1., 1.) * 8.;
  461. /*<       rad=360.0d0/twopi >*/
  462.     knstnt_1.rad = 360. / knstnt_1.twopi;
  463. /*<       xlog2=dlog(2.0d0) >*/
  464.     knstnt_1.xlog2 = log(2.);
  465. /*<       xlog10=dlog(10.0d0) >*/
  466.     knstnt_1.xlog10 = log(10.);
  467. /*<       root2=dsqrt(2.0d0) >*/
  468.     knstnt_1.root2 = sqrt(2.);
  469. /*<       nodata=1 >*/
  470.     nodata = 1;
  471.  
  472. /*  begin job */
  473.  
  474. /*<    10 if (keof.eq.1) go to 1000 >*/
  475. L10:
  476.     if (flags_1.keof == 1) {
  477.     goto L1000;
  478.     }
  479. /*<       call getcje >*/
  480.     getcje_();
  481. /*<       call second(time1) >*/
  482.     second_(&time1);
  483. /*<       icost1=icost >*/
  484.     icost1 = cje_1.icost;
  485. /*<       igoof=0 >*/
  486.     flags_1.igoof = 0;
  487. /*<       mode=0 >*/
  488.     status_1.mode = 0;
  489. /*<       nogo=0 >*/
  490.     flags_1.nogo = 0;
  491. /*<       call setmem(nodplc(1),maxmem) >*/
  492.     setmem_(nodplc, &memmgr_1.maxmem);
  493. /*<       if (nogo.ne.0) go to 1000 >*/
  494.     if (flags_1.nogo != 0) {
  495.     goto L1000;
  496.     }
  497. /*<       call zero8(rstats,50) >*/
  498.     zero8_(miscel_1.rstats, &c__50);
  499.  
  500. /*  read remainder of data deck and check for input errors */
  501.  
  502. /*<       call readin >*/
  503.     readin_();
  504. /*<       if (nogo.ne.0) go to 300 >*/
  505.     if (flags_1.nogo != 0) {
  506.     goto L300;
  507.     }
  508. /*<       if (keof.eq.1) go to 1000 >*/
  509.     if (flags_1.keof == 1) {
  510.     goto L1000;
  511.     }
  512. /*<       nodata=0 >*/
  513.     nodata = 0;
  514. /*<    50 call errchk >*/
  515. /* L50: */
  516.     errchk_();
  517. /*<       if (nogo.ne.0) go to 300 >*/
  518.     if (flags_1.nogo != 0) {
  519.     goto L300;
  520.     }
  521. /*<       call setup >*/
  522.     setup_();
  523. /*<       if (nogo.ne.0) go to 300 >*/
  524.     if (flags_1.nogo != 0) {
  525.     goto L300;
  526.     }
  527.  
  528. /*  change parameters and re-analisis */
  529.  
  530. /*<       if (numcyc.eq.0) go to 90 >*/
  531.     if (cirdat_1.numcyc == 0) {
  532.     goto L90;
  533.     }
  534. /*<    70 if (numcyc.ge.numalt) go to 310 >*/
  535. L70:
  536.     if (cirdat_1.numcyc >= cirdat_1.numalt) {
  537.     goto L310;
  538.     }
  539. /*<       numcyc=numcyc+1 >*/
  540.     ++cirdat_1.numcyc;
  541. /*<       call alter >*/
  542.     alter_();
  543. /*<       if (nogo.ne.0) go to 305 >*/
  544.     if (flags_1.nogo != 0) {
  545.     goto L305;
  546.     }
  547.  
  548. /*  cycle through temperatures */
  549.  
  550. /*<    90 itemno=1 >*/
  551. L90:
  552.     status_1.itemno = 1;
  553. /*<       if (numtem.eq.1) go to 110 >*/
  554.     if (tabinf_1.numtem == 1) {
  555.     goto L110;
  556.     }
  557. /*<   100 if (itemno.eq.numtem) go to 70 >*/
  558. L100:
  559.     if (status_1.itemno == tabinf_1.numtem) {
  560.     goto L70;
  561.     }
  562. /*<       itemno=itemno+1 >*/
  563.     ++status_1.itemno;
  564. /*<       call tmpupd >*/
  565.     tmpupd_();
  566.  
  567. /*  dc transfer curves */
  568.  
  569. /*<   110 if (icvflg.eq.0) go to 150 >*/
  570. L110:
  571.     if (dc_1.icvflg == 0) {
  572.     goto L150;
  573.     }
  574. /* ...  see routine *dctran* for explanation of *mode*, etc. */
  575. /*<       mode=1 >*/
  576.     status_1.mode = 1;
  577. /*<       modedc=3 >*/
  578.     status_1.modedc = 3;
  579. /*<       call dctran >*/
  580.     dctran_();
  581. /*<       call ovtpvt >*/
  582.     ovtpvt_();
  583. /*<       if (nogo.ne.0) go to 300 >*/
  584.     if (flags_1.nogo != 0) {
  585.     goto L300;
  586.     }
  587.  
  588. /*  small signal operating point */
  589.  
  590. /*<   150 if (kssop.gt.0) go to 170 >*/
  591. L150:
  592.     if (dc_1.kssop > 0) {
  593.     goto L170;
  594.     }
  595. /*<       if (jacflg.ne.0) go to 170 >*/
  596.     if (ac_1.jacflg != 0) {
  597.     goto L170;
  598.     }
  599. /*<       if ((icvflg+jtrflg).gt.0) go to 250 >*/
  600.     if (dc_1.icvflg + tran_1.jtrflg > 0) {
  601.     goto L250;
  602.     }
  603. /*<   170 mode=1 >*/
  604. L170:
  605.     status_1.mode = 1;
  606. /*<       modedc=1 >*/
  607.     status_1.modedc = 1;
  608. /*<       call dctran >*/
  609.     dctran_();
  610. /*<       if (nogo.ne.0) go to 300 >*/
  611.     if (flags_1.nogo != 0) {
  612.     goto L300;
  613.     }
  614. /*<       call dcop >*/
  615.     dcop_();
  616. /*<       if (nogo.ne.0) go to 300 >*/
  617.     if (flags_1.nogo != 0) {
  618.     goto L300;
  619.     }
  620.  
  621. /*  ac small signal analysis */
  622.  
  623. /*<   200 if (jacflg.eq.0) go to 250 >*/
  624. /* L200: */
  625.     if (ac_1.jacflg == 0) {
  626.     goto L250;
  627.     }
  628. /*<       mode=3 >*/
  629.     status_1.mode = 3;
  630. /*<       call acan >*/
  631.     acan_();
  632. /*<       call ovtpvt >*/
  633.     ovtpvt_();
  634. /*<       if (nogo.ne.0) go to 300 >*/
  635.     if (flags_1.nogo != 0) {
  636.     goto L300;
  637.     }
  638.  
  639. /*  transient analysis */
  640.  
  641. /*<   250 if (jtrflg.eq.0) go to 100 >*/
  642. L250:
  643.     if (tran_1.jtrflg == 0) {
  644.     goto L100;
  645.     }
  646. /*<       mode=1 >*/
  647.     status_1.mode = 1;
  648. /*<       modedc=2 >*/
  649.     status_1.modedc = 2;
  650. /*<       call dctran >*/
  651.     dctran_();
  652. /*<       if (nogo.ne.0) go to 300 >*/
  653.     if (flags_1.nogo != 0) {
  654.     goto L300;
  655.     }
  656. /*<       call dcop >*/
  657.     dcop_();
  658. /*<       if (nogo.ne.0) go to 300 >*/
  659.     if (flags_1.nogo != 0) {
  660.     goto L300;
  661.     }
  662. /*<       mode=2 >*/
  663.     status_1.mode = 2;
  664. /*<       call dctran >*/
  665.     dctran_();
  666. /*<       call ovtpvt >*/
  667.     ovtpvt_();
  668. /*<       if (nogo.ne.0) go to 300 >*/
  669.     if (flags_1.nogo != 0) {
  670.     goto L300;
  671.     }
  672. /*<       go to 100 >*/
  673.     goto L100;
  674.  
  675. /*  job concluded */
  676.  
  677. /*<   300 write (iofile,301) >*/
  678. L300:
  679.     io__11.ciunit = status_1.iofile;
  680.     s_wsfe(&io__11);
  681.     e_wsfe();
  682. /*<   301 format(1h0,9x,'***** job aborted') >*/
  683. /*<       nodata=0 >*/
  684.     nodata = 0;
  685. /*<       go to 320 >*/
  686.     goto L320;
  687. /*<   305 write (iofile,306) >*/
  688. L305:
  689.     io__12.ciunit = status_1.iofile;
  690.     s_wsfe(&io__12);
  691.     e_wsfe();
  692. /*<   306 format (1h0,9x,'***** this parameter change is illegal') >*/
  693. /*<   310 write (iofile,311) >*/
  694. L310:
  695.     io__13.ciunit = status_1.iofile;
  696.     s_wsfe(&io__13);
  697.     e_wsfe();
  698. /*<   311 format(1h0,/,9x,'job concluded') >*/
  699.  
  700. /*  job accounting */
  701.  
  702. /*<   320 continue >*/
  703. L320:
  704. /*<       numel=0 >*/
  705.     numel = 0;
  706. /*<       do 360 i=1,18 >*/
  707.     for (i = 1; i <= 18; ++i) {
  708. /*<   360 numel=numel+jelcnt(i) >*/
  709. /* L360: */
  710.     numel += cirdat_1.jelcnt[i - 1];
  711.     }
  712. /*<       numtem=max0(numtem-1,1) >*/
  713. /* Computing MAX */
  714.     i_1 = tabinf_1.numtem - 1;
  715.     tabinf_1.numtem = max(1,i_1);
  716. /*<       idist=min0(idist,1) >*/
  717.     ac_1.idist = min(ac_1.idist,1);
  718. /*<       if (iprnta.eq.0) go to 800 >*/
  719.     if (flags_1.iprnta == 0) {
  720.     goto L800;
  721.     }
  722. /*<       call title(-1,lwidth,1,acctit) >*/
  723.     title_(&c_n1, &miscel_1.lwidth, &c__1, acctit);
  724. /*<       write (iofile,361) nunods,ncnods,numnod,numel,(jelcnt(i),i=11,14) >*/
  725.     io__16.ciunit = status_1.iofile;
  726.     s_wsfe(&io__16);
  727.     do_fio(&c__1, (char *)&cirdat_1.nunods, (ftnlen)sizeof(integer));
  728.     do_fio(&c__1, (char *)&cirdat_1.ncnods, (ftnlen)sizeof(integer));
  729.     do_fio(&c__1, (char *)&cirdat_1.numnod, (ftnlen)sizeof(integer));
  730.     do_fio(&c__1, (char *)&numel, (ftnlen)sizeof(integer));
  731.     for (i = 11; i <= 14; ++i) {
  732.     do_fio(&c__1, (char *)&cirdat_1.jelcnt[i - 1], (ftnlen)sizeof(integer)
  733.         );
  734.     }
  735.     e_wsfe();
  736. /*<   361 format('   nunods ncnods numnod numel  diodes  bjts  jfets  mfets' >*/
  737. /*<      1   //,i9,2i7,i6,i8,i6,2i7) >*/
  738. /*<       write (iofile,371) numtem,icvflg,jtrflg,jacflg,inoise,idist,nogo >*/
  739.     io__17.ciunit = status_1.iofile;
  740.     s_wsfe(&io__17);
  741.     do_fio(&c__1, (char *)&tabinf_1.numtem, (ftnlen)sizeof(integer));
  742.     do_fio(&c__1, (char *)&dc_1.icvflg, (ftnlen)sizeof(integer));
  743.     do_fio(&c__1, (char *)&tran_1.jtrflg, (ftnlen)sizeof(integer));
  744.     do_fio(&c__1, (char *)&ac_1.jacflg, (ftnlen)sizeof(integer));
  745.     do_fio(&c__1, (char *)&ac_1.inoise, (ftnlen)sizeof(integer));
  746.     do_fio(&c__1, (char *)&ac_1.idist, (ftnlen)sizeof(integer));
  747.     do_fio(&c__1, (char *)&flags_1.nogo, (ftnlen)sizeof(integer));
  748.     e_wsfe();
  749. /*<   371 format(/'0  numtem icvflg jtrflg jacflg inoise  idist   nogo'/, >*/
  750. /*<      1   2h0 ,7i7) >*/
  751. /*<       write (iofile,381) rstats(20),rstats(21),rstats(22),rstats(23), >*/
  752. /*<      1   rstats(26),rstats(27) >*/
  753.     io__18.ciunit = status_1.iofile;
  754.     s_wsfe(&io__18);
  755.     do_fio(&c__1, (char *)&miscel_1.rstats[19], (ftnlen)sizeof(doublereal));
  756.     do_fio(&c__1, (char *)&miscel_1.rstats[20], (ftnlen)sizeof(doublereal));
  757.     do_fio(&c__1, (char *)&miscel_1.rstats[21], (ftnlen)sizeof(doublereal));
  758.     do_fio(&c__1, (char *)&miscel_1.rstats[22], (ftnlen)sizeof(doublereal));
  759.     do_fio(&c__1, (char *)&miscel_1.rstats[25], (ftnlen)sizeof(doublereal));
  760.     do_fio(&c__1, (char *)&miscel_1.rstats[26], (ftnlen)sizeof(doublereal));
  761.     e_wsfe();
  762. /*<   381 format(/'0  nstop   nttbr   nttar   ifill    iops    perspa'//, >*/
  763. /*<      1   1x,5f8.0,f9.3) >*/
  764. /*<       write (iofile,391) rstats(30),rstats(31),rstats(32),maxmem,maxuse, >*/
  765. /*<      1   cpyknt >*/
  766.     io__19.ciunit = status_1.iofile;
  767.     s_wsfe(&io__19);
  768.     do_fio(&c__1, (char *)&miscel_1.rstats[29], (ftnlen)sizeof(doublereal));
  769.     do_fio(&c__1, (char *)&miscel_1.rstats[30], (ftnlen)sizeof(doublereal));
  770.     do_fio(&c__1, (char *)&miscel_1.rstats[31], (ftnlen)sizeof(doublereal));
  771.     do_fio(&c__1, (char *)&memmgr_1.maxmem, (ftnlen)sizeof(integer));
  772.     do_fio(&c__1, (char *)&memmgr_1.maxuse, (ftnlen)sizeof(integer));
  773.     do_fio(&c__1, (char *)&memmgr_1.cpyknt, (ftnlen)sizeof(doublereal));
  774.     e_wsfe();
  775. /*<   391 format(/'0  numttp  numrtp  numnit  maxmem  memuse  copyknt',//, >*/
  776. /*<      1   2x,3f8.0,2x,i6,2x,i6,2x,f8.0) >*/
  777. /*<       write (iofile,401) (rstats(i),i=1,6),rstats(50),rstats(49), >*/
  778. /*<      1   rstats(46),(rstats(i),i=7,11) >*/
  779.     io__20.ciunit = status_1.iofile;
  780.     s_wsfe(&io__20);
  781.     for (i = 1; i <= 6; ++i) {
  782.     do_fio(&c__1, (char *)&miscel_1.rstats[i - 1], (ftnlen)sizeof(
  783.         doublereal));
  784.     }
  785.     do_fio(&c__1, (char *)&miscel_1.rstats[49], (ftnlen)sizeof(doublereal));
  786.     do_fio(&c__1, (char *)&miscel_1.rstats[48], (ftnlen)sizeof(doublereal));
  787.     do_fio(&c__1, (char *)&miscel_1.rstats[45], (ftnlen)sizeof(doublereal));
  788.     for (i = 7; i <= 11; ++i) {
  789.     do_fio(&c__1, (char *)&miscel_1.rstats[i - 1], (ftnlen)sizeof(
  790.         doublereal));
  791.     }
  792.     e_wsfe();
  793. /*<   401 format(/, >*/
  794. /*<      1   1h0,9x,'readin  ',12x,f10.2/, >*/
  795. /*<      2   1h0,9x,'setup   ',12x,f10.2/, >*/
  796. /*<      3   1h0,9x,'trcurv  ',12x,f10.2,10x,f6.0/, >*/
  797. /*<      4   1h0,9x,'dcan    ',12x,f10.2,10x,f6.0/, >*/
  798. /*<      5   1h0,9x,'dcdcmp  ',12x,f10.3,10x,f6.0/, >*/
  799. /*<      6   1h0,9x,'dcsol   ',12x,f10.3/, >*/
  800. /*<      7   1h0,9x,'acan    ',12x,f10.2,10x,f6.0/, >*/
  801. /*<      8   1h0,9x,'tranan  ',12x,f10.2,10x,f6.0/, >*/
  802. /*<      9   1h0,9x,'output  ',12x,f10.2) >*/
  803. /*<       write (iofile,402) rstats(45),rstats(48),rstats(47),rstats(44), >*/
  804. /*<      1   rstats(43) >*/
  805.     io__21.ciunit = status_1.iofile;
  806.     s_wsfe(&io__21);
  807.     do_fio(&c__1, (char *)&miscel_1.rstats[44], (ftnlen)sizeof(doublereal));
  808.     do_fio(&c__1, (char *)&miscel_1.rstats[47], (ftnlen)sizeof(doublereal));
  809.     do_fio(&c__1, (char *)&miscel_1.rstats[46], (ftnlen)sizeof(doublereal));
  810.     do_fio(&c__1, (char *)&miscel_1.rstats[43], (ftnlen)sizeof(doublereal));
  811.     do_fio(&c__1, (char *)&miscel_1.rstats[42], (ftnlen)sizeof(doublereal));
  812.     e_wsfe();
  813. /*<   402 format( >*/
  814. /*<      1   1h0,9x,'load    ',12x,f10.3/, >*/
  815. /*<      2   1h0,9x,'codgen  ',12x,f10.3,10x,f6.0/, >*/
  816. /*<      3   1h0,9x,'codexc  ',12x,f10.3/, >*/
  817. /*<      4   1h0,9x,'macins  ',12x,f10.3) >*/
  818. /*<   800 call getcje >*/
  819. L800:
  820.     getcje_();
  821. /*<       call second(time2) >*/
  822.     second_(&time2);
  823. /*<       et=time2-time1 >*/
  824.     et = time2 - time1;
  825. /*<       tcost=dble(icost-icost1)/100.0d0 >*/
  826.     tcost = (doublereal) (cje_1.icost - icost1) / 100.;
  827. /*<       if (iprnta.eq.0) go to 810 >*/
  828.     if (flags_1.iprnta == 0) {
  829.     goto L810;
  830.     }
  831. /*<       ohead=et-(rstats(1)+rstats(2)+rstats(3)+rstats(5)+rstats(7) >*/
  832. /*<      1   +rstats(9)+rstats(11)) >*/
  833.     ohead = et - (miscel_1.rstats[0] + miscel_1.rstats[1] + miscel_1.rstats[2]
  834.          + miscel_1.rstats[4] + miscel_1.rstats[6] + miscel_1.rstats[8] + 
  835.         miscel_1.rstats[10]);
  836. /*<       write (iofile,801) ohead >*/
  837.     io__26.ciunit = status_1.iofile;
  838.     s_wsfe(&io__26);
  839.     do_fio(&c__1, (char *)&ohead, (ftnlen)sizeof(doublereal));
  840.     e_wsfe();
  841. /*<   801 format(1h0,9x,'overhead',12x,f10.2) >*/
  842. /*<   810 write (iofile,811) et >*/
  843. L810:
  844.     io__27.ciunit = status_1.iofile;
  845.     s_wsfe(&io__27);
  846.     do_fio(&c__1, (char *)&et, (ftnlen)sizeof(doublereal));
  847.     e_wsfe();
  848. /*<   811 format(1h0,9x,'total job time      ',f10.2) >*/
  849. /*<       rstats(33)=cpyknt >*/
  850.     miscel_1.rstats[32] = memmgr_1.cpyknt;
  851. /*<       rstats(34)=et >*/
  852.     miscel_1.rstats[33] = et;
  853. /*<       rstats(35)=tcost >*/
  854.     miscel_1.rstats[34] = tcost;
  855. /*<       rstats(36)=ohead >*/
  856.     miscel_1.rstats[35] = ohead;
  857. /*<   900 if ((maxtim-itime).ge.limtim) go to 10 >*/
  858. /* L900: */
  859.     if (cje_1.maxtim - cje_1.itime >= flags_1.limtim) {
  860.     goto L10;
  861.     }
  862. /*<       write (iofile,901) >*/
  863.     io__28.ciunit = status_1.iofile;
  864.     s_wsfe(&io__28);
  865.     e_wsfe();
  866. /*<   901 format('1warning:  further analysis stopped due to cpu time limit' >*/
  867. /*<      1/) >*/
  868. /*<  1000 if(nodata.ne.0) write(iofile,1001) >*/
  869. L1000:
  870.     if (nodata != 0) {
  871.     io__29.ciunit = status_1.iofile;
  872.     s_wsfe(&io__29);
  873.     e_wsfe();
  874.     }
  875. /*<  1001 format(/1x,'input deck (file) contains no data.') >*/
  876. /*<       stop >*/
  877.     s_stop("", 0L);
  878. /*<       end >*/
  879. } /* MAIN__ */
  880.  
  881. #undef cvalue
  882. #undef nodplc
  883. #undef ahdr3
  884. #undef ahdr2
  885. #undef ahdr1
  886. #undef acctit
  887. #undef ablnk
  888.  
  889.  
  890. /* Main program alias */ int spice_ () { MAIN__ (); }
  891.